Skip to content

Fix/337 move metrics to cache refresh#338

Open
gimballock wants to merge 1 commit intostratum-mining:mainfrom
fossatmara:fix/337-move-metrics-to-cache-refresh
Open

Fix/337 move metrics to cache refresh#338
gimballock wants to merge 1 commit intostratum-mining:mainfrom
fossatmara:fix/337-move-metrics-to-cache-refresh

Conversation

@gimballock
Copy link

No description provided.

@gimballock gimballock force-pushed the fix/337-move-metrics-to-cache-refresh branch 3 times, most recently from 56a1252 to a0e972e Compare March 17, 2026 23:06
@gimballock
Copy link
Author

Addresses #337

@gimballock gimballock force-pushed the fix/337-move-metrics-to-cache-refresh branch 4 times, most recently from 0a55dce to 13457ee Compare March 18, 2026 16:59
@gimballock gimballock changed the title [Draft] Fix/337 move metrics to cache refresh Fix/337 move metrics to cache refresh Mar 18, 2026
@gimballock gimballock force-pushed the fix/337-move-metrics-to-cache-refresh branch 2 times, most recently from 832f7db to 04dfe60 Compare March 20, 2026 14:05
…hotCache::refresh (stratum-mining#337)

Move all Prometheus gauge updates (set + stale-label removal) out of the
/metrics HTTP handler and into SnapshotCache::refresh(), which runs as a
periodic background task. This eliminates the GaugeVec reset gap where
label series momentarily disappeared on every scrape.

Changes:
- SnapshotCache now owns PrometheusMetrics and PreviousLabelSets
- refresh() updates snapshot data AND Prometheus gauges atomically
- /metrics handler reduced to: set uptime gauge, gather, encode
- ServerState simplified (no more PreviousLabelSets or Mutex)
- Tests updated to wire metrics through cache via with_metrics()
- Integration tests: replace fixed-sleep assertions with
  poll_until_metric_gte (100ms poll, 5s deadline) for CI resilience
- Clone impl preserves previous_labels for correct stale-label detection
- debug-level tracing on stale label removal errors
- debug_assert on with_metrics double-attachment

Closes stratum-mining#337
@gimballock gimballock force-pushed the fix/337-move-metrics-to-cache-refresh branch from 04dfe60 to 1b016e3 Compare March 23, 2026 14:14
@GitGab19 GitGab19 linked an issue Mar 23, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix GaugeVec reset gap in handle_prometheus_metrics

1 participant